home *** CD-ROM | disk | FTP | other *** search
- /* virusDemo.c -- Demonstration of virus self-diagnosis.
- Copyright © 1989 by Michael S. Morton.
- */
-
- /* History:
- 26-Nov-89 -- MM -- First version.
- */
-
- #include "virusCheck.h" /* get our own prototypes */
-
- /* Local and C library prototypes: */
- void main (void);
- int printf (char *formatn, ...);
- int getche (void);
-
- /* NOTE: The total length of the CODE resources will vary with your
- development system, so you’ll have to calibrate this.
- */
- #define CODELENGTH 15948L /* actual length of CODE resources */
-
- /* NOTE: The number of CODE resources will vary with how you arrange
- your project. This count assumes that all source files and libraries
- are grouped into a single segment. The count is higher because of
- the resources which Think C adds.
- */
- #define CODECOUNT (1+2) /* actual count of CODE resources */
-
- #define WRONGLENGTH (CODELENGTH+1) /* guaranteed to fail */
- #define WRONGCOUNT (CODECOUNT+1) /* ditto */
-
- void main ()
- { char dbgResponse; /* user response for debugger query */
- short debugger; /* debugger installed? 1=y, -1=n */
-
- if (! Count1Resources ('CODE'))
- { SysBeep (5);
- printf ("This demo must be run standalone, not within Think C\n");
- printf ("Press any key to exit… ");
- getche ();
- ExitToShell ();
- }
-
- printf ("Report unexpected errors with the debugger? ");
- dbgResponse = getche ();
- printf ("\n");
- if ((dbgResponse == 'y') || (dbgResponse == 'Y'))
- debugger = 1;
- else debugger = -1;
-
- printf ("\nChecking -- shouldn’t fail… ");
- if (vCodeCheck (CODECOUNT, CODELENGTH, debugger))
- printf ("FAILED! *** This application is apparently infected. ***\n");
- else printf ("didn’t fail.\n");
-
- printf ("\nChecking -- should fail on count… ");
- if (vCodeCheck (WRONGCOUNT, CODELENGTH, -1))
- printf ("failed.\n");
- else printf ("DIDN’T FAIL!\n");
-
- printf ("\nChecking -- should fail on length… ");
- if (vCodeCheck (CODECOUNT, WRONGLENGTH, -1))
- printf ("failed.\n");
- else printf ("DIDN’T FAIL!\n");
-
- printf ("\nPress any key to exit… ");
- getche ();
- } /* end of main () */
-